<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录页面</title>
<script type="text/javascript" src="${pageContext.servletContext.contextPath }/js/jquery-1.11.1.js"></script>
<script type="text/javascript">
     $(function(){
    	 $("[type=button]").click(function(){
    		 $.ajax({
    			 type:"post",
    			 url:"${pageContext.servletContext.contextPath }/doLogin",
    			 data:$("#myform").serialize(),
    			 dataType:"json",
    			 success:function(result){
    				if(result.user_code!=null){
    					location.href="${pageContext.servletContext.contextPath }/success.jsp";
    				}else{
    					alert("用户名或者密码错误！");
    				}
    			 },
    			 error:function(result){
    				 alert("系统出现错误");
    			 }
    		 });
    	 });
     });
</script>
</head>
<body>
    <form  id="myform">
       请输入用户名：<input type="text" name="user_code">
       请输入密码：<input type="text" name="password">
       <input type="button" value="提交">
    </form>
</body>
</html>